#!/usr/bin/python
# -*- coding: utf-8 -*-
import scipy.io

from pylab import title
import matplotlib.cm as cm
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt


def saveAsMatlab(file_name, M):
    scipy.io.savemat(file_name + '.mat', {'m': M})  # Note: this routine save a dictionary!


def loadAsMatlab(file_name):
    dict = scipy.io.loadmat(file_name)  # Note: this routine loads a dictionary!
    return dict['m']


def plotImage(file_name):
    (descriptor, imag) = loadImage(file_name)
    im = plt.imshow(imag, interpolation='bilinear', cmap=cm.gray,
                    origin='lower')
    title(file_name)
    plt.show()


def plot2Images(imag1, imag2, title1, title2, orig='lower'):
    plt.figure(2, figsize=(10, 5))
    plt.clf()

    plt.subplot(1, 2, 1)

    im1 = plt.imshow(imag1, interpolation='bilinear', origin=orig)
  # im1 = plt.imshow(imag1, interpolation='nearest', cmap=cm.gray, origin='lower')
  #  im1 = plt.imshow(imag1, interpolation='nearest', origin='lower')
    plt.colorbar()
    title(title1)

    plt.subplot(1, 2, 2)

    im2 = plt.imshow(imag2, interpolation='bilinear', origin=orig)
  # im2 = plt.imshow(imag2, interpolation='nearest', cmap=cm.gray, origin='lower')

  # im2 = plt.imshow(imag2, interpolation='nearest', origin='lower')
    title(title2)
    plt.colorbar()
    plt.show()


def plotOneDGraph(x, y, title_name):
    plt.figure()
    fig.gca()
    ax.axis('equal')
    plt.plot(x, y)
    title(title_name)
    plt.show()


